package com.ttg.utils;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class CodeRuleUtil {

    /**
     * 微信的条码规则是10-15开头
     * @param str
     * @return
     */
    public static boolean isWeixinCode(String str) {
        Pattern pattern = Pattern.compile("^1[0-5][0-9]*");
        Matcher isNum = pattern.matcher(str);
        if (!isNum.matches()) {
            return false;
        }
        return true;
    }

    /**
     * 支付宝的条码规则是25-30开头
     * @param str
     * @return
     */
    public static boolean isAlipayCode(String str) {
        Pattern pattern = Pattern.compile("^2[5-9][0-9]*|^30[0-9]*");
        Matcher isNum = pattern.matcher(str);
        if (!isNum.matches()) {
            return false;
        }
        return true;
    }


    /**
     * 云闪付的条码规则是62开头
     * @param str
     * @return
     */
    public static boolean isUnionCode(String str) {
        Pattern pattern = Pattern.compile("^62[0-9]*");
        Matcher isNum = pattern.matcher(str);
        if (!isNum.matches()) {
            return false;
        }
        return true;
    }
}
